package com.ruitu.mall_98_2.order.fragment;

import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.ImageSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.beanu.arad.Arad;
import com.beanu.arad.base.my_base.Config;
import com.beanu.arad.base.my_base.WineRefreshHeader;
import com.beanu.arad.base.my_base.base_list.ListBaseAdapter;
import com.beanu.arad.base.my_base.base_list.SuperViewHolder;
import com.beanu.arad.utils.Logg;
import com.beanu.arad.widget.dialog.CustomAlertDialog;
import com.bumptech.glide.Glide;
import com.github.jdsjlzx.interfaces.OnRefreshListener;
import com.github.jdsjlzx.recyclerview.LRecyclerView;
import com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter;
import com.ruitu.mall_98_2.R;
import com.ruitu.mall_98_2.base.BaseFragment;
import com.ruitu.mall_98_2.mine.AfterSaleActivity;
import com.ruitu.mall_98_2.mvp.contract.OrderContract;
import com.ruitu.mall_98_2.mvp.model.OrderModel;
import com.ruitu.mall_98_2.mvp.presenter.OrderPresenter;
import com.ruitu.mall_98_2.order.CheckLogisticsActivity;
import com.ruitu.mall_98_2.order.CommentActivity;
import com.ruitu.mall_98_2.order.OrderDetailsActivity;
import com.ruitu.mall_98_2.order.PayOrderActivity;
import com.ruitu.mall_98_2.order.WaitingPayOrderDetailsActivity;
import com.ruitu.router_module.A_Rutils;
import com.ruitu.router_module.AppHolder;
import com.ruitu.router_module.bean.api.PageModel;
import com.ruitu.router_module.bean.order.ConfirOrder;
import com.ruitu.router_module.bean.order.Order;
import com.ruitu.router_module.bean.order.OrderList;
import com.ruitu.router_module.bean.order.SmallOrder;

import java.util.List;

public class OrderFragment extends BaseFragment<OrderPresenter, OrderModel> implements OrderContract.View {
    private DataAdapter adapter;
    private int page = 1;
    private DataWaitingPayAdapter dataWaitingPayAdapter;
    private LRecyclerViewAdapter recyclerViewAdapter;
    private LinearLayoutManager manager;
    private LRecyclerView lRecyclerView;
    private List<SmallOrder> smallOrders;
    private Order order;
    private AlertDialog alertDialog;
    private CustomAlertDialog customAlertDialog;
    private Intent intent;

    public static OrderFragment newInstance() {
        Bundle args = new Bundle();
        OrderFragment fragment = new OrderFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        alertDialog = new AlertDialog.Builder(getContext()).create();
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_order, null);
        lRecyclerView = view.findViewById(R.id.lRecyclerView);
        //刷新的头部
        lRecyclerView.setRefreshHeader(new WineRefreshHeader(getActivity()));
        manager = new LinearLayoutManager(getContext());
        lRecyclerView.setLayoutManager(manager);
        adapter = new DataAdapter(getContext());
        recyclerViewAdapter = new LRecyclerViewAdapter(adapter);
        lRecyclerView.setAdapter(recyclerViewAdapter);
        initRecyclerView(view);
        return view;
    }

    //初始化头部的recyclerView
    protected void initRecyclerView(View v) {
        View view = View.inflate(getContext(), R.layout.item_all_order_header, null);
        RecyclerView recyclerView = view.findViewById(R.id.recyclerView);
        manager = new LinearLayoutManager(getContext());
        recyclerView.setLayoutManager(manager);
        dataWaitingPayAdapter = new DataWaitingPayAdapter(getContext());
        recyclerView.setAdapter(dataWaitingPayAdapter);
        recyclerViewAdapter.addHeaderView(view);

        lRecyclerView.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh() {
                reReq();
            }
        });

    }

    protected void reReq() {
        showProgress();
        mPresenter.orderInfo(AppHolder.instance().getUser().getAccountId());
    }

    public void getData() {
        mPresenter.getOtherAllOrders(AppHolder.instance().getUser().getAccountId(), "0", 1 + "", "1000");
    }

    @Override
    public void setData1(PageModel<SmallOrder> orders) {
        this.smallOrders = orders.getDataList();
        lRecyclerView.refreshComplete(20);
        adapter.setDataList(orders.getDataList());
        setData(isDataEmpty(smallOrders) && isDataEmpty(order.getOrderList()), lRecyclerView);
    }

    @Override
    public void setData(Order orders) {
        this.order = orders;
        dataWaitingPayAdapter.setDataList(orders.getOrderList());
        getData();
    }

    @Override
    public void setSuc() {
        reReq();
    }

    @Override
    public void setFail() {
        showError();
        lRecyclerView.refreshComplete(20);
    }

    @Override
    protected void getReData() {
        super.getReData();
//        hideProgress();
//        showProgress();
        reReq();
    }

    @Override
    public void onResume() {
        super.onResume();
        reReq();
    }

    class DataAdapter extends ListBaseAdapter<SmallOrder> {

        public DataAdapter(Context context) {
            super(context);
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_order;
        }

        @Override
        public void onBindItemHolder(SuperViewHolder holder, final int position) {
            TextView tv_pay_model = holder.getView(R.id.tv_pay_model);
            ImageView iv_commodity = holder.getView(R.id.iv_commodity);
            ImageView iv_order_type = holder.getView(R.id.iv_order_type);
            TextView tv_commodity_name = holder.getView(R.id.tv_commodity_name);
            TextView tv_commodity_info = holder.getView(R.id.tv_commodity_info);
            TextView tv_commodity_price = holder.getView(R.id.tv_commodity_price);
            TextView tv_commodity_num = holder.getView(R.id.tv_commodity_num);
            TextView tv_pay_type_adj = holder.getView(R.id.tv_pay_type_adj);
            TextView tv_actually_paid = holder.getView(R.id.tv_actually_paid);
            TextView tv_company_name = holder.getView(R.id.tv_company_name);

            TextView tv_application_for_drawback = holder.getView(R.id.tv_application_for_drawback);
            RelativeLayout rl_waiting_send = holder.getView(R.id.rl_waiting_send);
            TextView tv_waiting_reciver = holder.getView(R.id.tv_waiting_reciver);
            TextView tv_check_logistics = holder.getView(R.id.tv_check_logistics);
            LinearLayout ll_waiting_reciver = holder.getView(R.id.ll_waiting_reciver);
            TextView tv_waiting_comment = holder.getView(R.id.tv_waiting_comment);
            RelativeLayout rl_waiting_comment = holder.getView(R.id.rl_waiting_comment);
            LinearLayout ll_order_cancle = holder.getView(R.id.ll_order_cancle);
            TextView tv_cancel_delete = holder.getView(R.id.tv_cancel_delete);
            TextView tv_expressage_total = holder.getView(R.id.tv_expressage_total);
            LinearLayout ll_small_item = holder.getView(R.id.ll_small_item);
            LinearLayout ll_xiajia = holder.getView(R.id.ll_xiajia);
            RelativeLayout rl_company = holder.getView(R.id.rl_company);
            ImageView iv_company_logo = holder.getView(R.id.iv_company_logo);
            final SmallOrder smallOrder = mDataList.get(position);
            String pay_type_adj = null;
            switch (smallOrder.getOrderStatus()) {
                case "1":
                    pay_type_adj = "已取消";
                    ll_order_cancle.setVisibility(View.VISIBLE);
                    rl_waiting_send.setVisibility(View.GONE);
                    ll_waiting_reciver.setVisibility(View.GONE);
                    rl_waiting_comment.setVisibility(View.GONE);
                    if (TextUtils.equals(smallOrder.getGoodStatus(),"0")){
                        ll_xiajia.setVisibility(View.VISIBLE);
                    }else if (TextUtils.equals(smallOrder.getGoodStatus(),"1")){
                        ll_xiajia.setVisibility(View.GONE);
                    }
                    break;
                case "2":
                    pay_type_adj = "待发货";
                    rl_waiting_send.setVisibility(View.GONE);
                    ll_order_cancle.setVisibility(View.GONE);
                    ll_waiting_reciver.setVisibility(View.GONE);
                    rl_waiting_comment.setVisibility(View.GONE);
                    break;
//                case "3":
//                    pay_type_adj = "已取消";
//                    break;
                case "4":
                    pay_type_adj = "待收货";
                    ll_waiting_reciver.setVisibility(View.VISIBLE);
                    ll_order_cancle.setVisibility(View.GONE);
                    rl_waiting_send.setVisibility(View.GONE);
                    rl_waiting_comment.setVisibility(View.GONE);
                    break;
                case "5":
                    pay_type_adj = "待评价";
                    rl_waiting_comment.setVisibility(View.VISIBLE);
                    ll_waiting_reciver.setVisibility(View.GONE);
                    ll_order_cancle.setVisibility(View.GONE);
                    rl_waiting_send.setVisibility(View.GONE);
                    break;
                case "6":
                    pay_type_adj = "申请售后中";
                    rl_waiting_comment.setVisibility(View.GONE);
                    ll_waiting_reciver.setVisibility(View.GONE);
                    ll_order_cancle.setVisibility(View.GONE);
                    rl_waiting_send.setVisibility(View.GONE);
                    break;
                case "7":
                    pay_type_adj = "订单完成";
                    rl_waiting_comment.setVisibility(View.GONE);
                    ll_waiting_reciver.setVisibility(View.GONE);
                    ll_order_cancle.setVisibility(View.GONE);
                    rl_waiting_send.setVisibility(View.GONE);
                    if (TextUtils.equals(smallOrder.getGoodStatus(),"0")){
                        ll_xiajia.setVisibility(View.VISIBLE);
                    }else if (TextUtils.equals(smallOrder.getGoodStatus(),"1")){
                        ll_xiajia.setVisibility(View.GONE);
                    }
                    break;
                case "8":
                    pay_type_adj = "退款完成";
                    rl_waiting_comment.setVisibility(View.GONE);
                    ll_waiting_reciver.setVisibility(View.GONE);
                    ll_order_cancle.setVisibility(View.GONE);
                    rl_waiting_send.setVisibility(View.GONE);
                    break;
                default:
                    break;
            }
            tv_expressage_total.setText("(包含运费" + smallOrder.getFreight() + "元)");
            if (Double.parseDouble(smallOrder.getFreight()) > 0) {
                tv_expressage_total.setVisibility(View.VISIBLE);
            } else {
                tv_expressage_total.setVisibility(View.GONE);
            }
            SpannableString spannableString = new SpannableString("   " + smallOrder.getGoodsName());

            Drawable drawable = null;
            if (!TextUtils.isEmpty(smallOrder.getOrderType())) {
                switch (smallOrder.getOrderType()) {
                    case "3":
                        drawable = mContext.getResources().getDrawable(R.mipmap.collage);
                        break;
                    case "2":
                        drawable = mContext.getResources().getDrawable(R.mipmap.reserve);
                        break;
                    case "1":
                        drawable = mContext.getResources().getDrawable(R.mipmap.presale);
                        break;
                    default:

                        break;
                }
            }
            ImageSpan imageSpan = new ImageSpan(drawable);
            if (drawable == null) {
                tv_commodity_name.setText(smallOrder.getGoodsName());
            } else {
                drawable.setBounds(0, 0, 100, 50);
                spannableString.setSpan(imageSpan, 0, 2, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
                tv_commodity_name.setText(spannableString);
            }

            tv_company_name.setText(smallOrder.getCompanyName());
            tv_pay_model.setText(pay_type_adj);
            Glide.with(mContext).load(Config.BASE_URL + smallOrder.getGoodsUrl()).apply(Arad.opts).into(iv_commodity);
            Glide.with(mContext).load(Config.BASE_URL + smallOrder.getCompanyLogo()).apply(Arad.opts_shop).into(iv_company_logo);
//            tv_commodity_name.setText(smallOrder.getGoodsName());
            tv_commodity_info.setText(smallOrder.getSkuContent());
            tv_commodity_num.setText("x" + smallOrder.getQuantity());
            tv_commodity_price.setText("￥" + smallOrder.getGoodsTotal());
            if (smallOrder.getOrderStatus().equals("8")) {
                tv_pay_type_adj.setText("");
                tv_actually_paid.setText("退款成功:" + smallOrder.getOrderTotal() + "元");
            } else {
                tv_pay_type_adj.setText("共" + smallOrder.getQuantity() + "件商品");
                tv_actually_paid.setText("实付款:" + smallOrder.getOrderTotal() + "元");
            }
            final Bundle bundle = new Bundle();
            ll_small_item.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (smallOrder.getOrderStatus().equals("6") || smallOrder.getOrderStatus().equals("8")) {
                        bundle.putSerializable("id", smallOrder.getId());
                        startActivity(AfterSalesDetailActivity.class, bundle);
                    } else {
                        bundle.putSerializable("smallOrder", smallOrder);
                        startActivity(OrderDetailsActivity.class, bundle);
                    }
                }
            });

            tv_application_for_drawback.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    bundle.putSerializable("smallOrder", smallOrder);
                    startActivity(AfterSaleActivity.class, bundle);
                }
            });

            //确认收货
            tv_waiting_reciver.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    customAlertDialog = new CustomAlertDialog(mContext, "确定确认收货吗?", new CustomAlertDialog.OkOnClickListener() {
                        @Override
                        public void OkOnClick() {
                            showProgress();
                            mPresenter.qrsh(smallOrder.getOrderId());
                            customAlertDialog.dismiss();
                        }
                    });
                    customAlertDialog.show();
                }
            });

            //查看物流
            tv_check_logistics.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Logg.i("Position: " + position);
                    bundle.putSerializable("smallOrder", smallOrder);
                    startActivity(CheckLogisticsActivity.class, bundle);
                }
            });

            //评论
            tv_waiting_comment.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    bundle.putSerializable("smallOrder", smallOrder);
                    startActivity(CommentActivity.class, bundle);
                }
            });

            //删除
            tv_cancel_delete.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Logg.i("Position: " + position);
                    customAlertDialog = new CustomAlertDialog(mContext, "确定删除该订单吗?", new CustomAlertDialog.OkOnClickListener() {
                        @Override
                        public void OkOnClick() {
                            showProgress();
                            mPresenter.deleteOrder(smallOrder.getOrderId());
                            customAlertDialog.dismiss();
                        }
                    });
                    customAlertDialog.show();
                }
            });

            tv_company_name.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    try {
                        bundle.putString("companyId", smallOrder.getCompanyId());
                        A_Rutils.startActivity(mContext, "com.ruitu.mall_98_1.product.activity.ShopDetailActivity", bundle);
                    } catch (ClassNotFoundException e) {
                        e.printStackTrace();
                    }
                }
            });

        }

    }

    class DataWaitingPayAdapter extends ListBaseAdapter<OrderList> {

        public DataWaitingPayAdapter(Context context) {
            super(context);
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_data_waiting_pay;
        }

        @Override
        public void onBindItemHolder(SuperViewHolder holder, final int position) {
            TextView tv_company_name = holder.getView(R.id.tv_company_name);
            TextView tv_pay_model = holder.getView(R.id.tv_pay_model);
            TextView tv_actually_paid = holder.getView(R.id.tv_actually_paid);
            TextView tv_cancle_order = holder.getView(R.id.tv_cancle_order);
            final TextView tv_waiting_pay = holder.getView(R.id.tv_waiting_pay);
            TextView tv_down_payment_status = holder.getView(R.id.tv_down_payment_status);
            TextView tv_down_payment = holder.getView(R.id.tv_down_payment);
            TextView tv_balance_payment = holder.getView(R.id.tv_balance_payment);
            TextView tv_balance_payment_status = holder.getView(R.id.tv_balance_payment_status);
            LinearLayout ll_advance_massege = holder.getView(R.id.ll_advance_massege);
            LinearLayout ll_btn = holder.getView(R.id.ll_btn);
            LinearLayout ll_need_pay = holder.getView(R.id.ll_need_pay);
            LinearLayout ll_balance_payment = holder.getView(R.id.ll_balance_payment);
            final OrderList orderList = mDataList.get(position);
            //当前为预售的订单状态车里
            if (TextUtils.equals(orderList.getOrderType(), "1") || TextUtils.equals("2", orderList.getOrderType())) {
                ll_need_pay.setVisibility(View.GONE);
                if (TextUtils.equals(orderList.getIsPayOver(), "2")) {//已经支付订金
                    ll_advance_massege.setVisibility(View.VISIBLE);
                    ll_balance_payment.setVisibility(View.VISIBLE);
                    ll_btn.setVisibility(View.GONE);
                    tv_cancle_order.setVisibility(View.GONE);
                    tv_down_payment_status.setText("已支付订金:");
                    tv_balance_payment_status.setText("需付尾款:");
                    tv_down_payment.setText("￥" + orderList.getAdvanceMoney());
                    tv_balance_payment.setText("￥" + orderList.getTailMoney());

                } else if (TextUtils.equals(orderList.getIsPayOver(), "4")) {//等待支付尾款
                    ll_advance_massege.setVisibility(View.VISIBLE);
                    ll_balance_payment.setVisibility(View.VISIBLE);
                    ll_btn.setVisibility(View.VISIBLE);
                    tv_down_payment_status.setText("已支付订金:");
                    tv_balance_payment_status.setText("需付尾款:");
                    tv_down_payment.setText("￥" + orderList.getAdvanceMoney());
                    tv_balance_payment.setText("￥" + orderList.getTailMoney());
                    tv_waiting_pay.setText("支付尾款");
                    tv_cancle_order.setVisibility(View.GONE);
                } else if (TextUtils.equals(orderList.getIsPayOver(), "0")) {//待支付订金
                    tv_down_payment_status.setText("需付订金:");
                    tv_balance_payment_status.setText("尾款:");
                    tv_waiting_pay.setText("支付订金");
                    tv_down_payment.setText("￥" + orderList.getAdvanceMoney());
                    tv_balance_payment.setText("￥" + orderList.getTailMoney());
                    ll_btn.setVisibility(View.VISIBLE);
                    tv_cancle_order.setVisibility(View.VISIBLE);
                }
            } else {
                ll_advance_massege.setVisibility(View.GONE);
                ll_need_pay.setVisibility(View.VISIBLE);
                ll_btn.setVisibility(View.VISIBLE);
                tv_cancle_order.setVisibility(View.VISIBLE);
                tv_waiting_pay.setText("去支付");
                tv_pay_model.setText("等待买家付款");
            }

            tv_actually_paid.setText("需付款:" + orderList.getOrderTotal() + "元");
            tv_company_name.setText(orderList.getCompanyName());
            RecyclerView recyclerView = holder.getView(R.id.recyclerView);
            LinearLayoutManager manager = new LinearLayoutManager(mContext);
            recyclerView.setLayoutManager(manager);
            DataAdapter2 adapter2 = new DataAdapter2(mContext);
            recyclerView.setAdapter(adapter2);
            adapter2.setDataList(orderList.getOrderDetails());

            adapter2.setOnItemClickListener(new OnItemClickListener() {
                @Override
                public void onItemClick(View itemView, int position) {
                    Logg.i(position + "");
                    intent = new Intent(getContext(), WaitingPayOrderDetailsActivity.class);
                    intent.putExtra("orderList", orderList);
                    startActivity(intent);
                }
            });

            tv_cancle_order.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    customAlertDialog = new CustomAlertDialog(mContext, "确定取消订单吗?", new CustomAlertDialog.OkOnClickListener() {
                        @Override
                        public void OkOnClick() {
                            showProgress();
                            mPresenter.cancelOrder(orderList.getId());
                            customAlertDialog.dismiss();
                        }
                    });
                    customAlertDialog.show();
                }
            });

            tv_waiting_pay.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (tv_waiting_pay.getText().equals("支付定金") | tv_waiting_pay.getText().equals("支付尾款")) {
                        ConfirOrder confirOrder = new ConfirOrder();
                        confirOrder.setId(orderList.getId());
                        confirOrder.setCollectGoodsAddress(orderList.getCollectGoodsAddress());
                        confirOrder.setCollectGoodsPhone(orderList.getCollectGoodsPhone());
                        confirOrder.setConsigneeName(orderList.getConsigneeName());
                        confirOrder.setOrderProvinceCode(orderList.getOrderProvinceCode());
                        confirOrder.setOrderCityCode(orderList.getOrderCountyCode());
                        confirOrder.setOrderCountyCode(orderList.getOrderCountyCode());
                        confirOrder.setOrderTotal(orderList.getOrderTotal());
                        confirOrder.setOrderType(orderList.getOrderType());
                        confirOrder.setIsPayOver(orderList.getIsPayOver());
                        intent = new Intent(mContext, PayOrderActivity.class);
                        intent.putExtra("confirOrder", confirOrder);
                        startActivity(intent);
                    } else {
                        ConfirOrder confirOrder = new ConfirOrder();
                        confirOrder.setId(orderList.getId());
                        confirOrder.setOrderTotal(orderList.getOrderTotal());
                        intent = new Intent(mContext, PayOrderActivity.class);
                        intent.putExtra("confirOrder", confirOrder);
                        startActivity(intent);
                    }
                }
            });
        }
    }

    class DataAdapter2 extends ListBaseAdapter<OrderList.OrderDetailsBean> {

        public DataAdapter2(Context context) {
            super(context);
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_data_waiting_pay_commodity;
        }

        @Override
        public void onBindItemHolder(SuperViewHolder holder, int position) {
            ImageView iv_commodity = holder.getView(R.id.iv_commodity);
            ImageView iv_order_type = holder.getView(R.id.iv_order_type);
            TextView tv_commodity_name = holder.getView(R.id.tv_commodity_name);
            TextView tv_commodity_info = holder.getView(R.id.tv_commodity_info);
            TextView tv_commodity_price = holder.getView(R.id.tv_commodity_price);
            TextView tv_commodity_num = holder.getView(R.id.tv_commodity_num);
            LinearLayout ll_xiajia = holder.getView(R.id.ll_xiajia);
            OrderList.OrderDetailsBean orderDetailsBean = mDataList.get(position);
            SpannableString spannableString = new SpannableString("   " + orderDetailsBean.getGoodsName());

            Drawable drawable = null;
            if (!TextUtils.isEmpty(orderDetailsBean.getOrderType())) {
                switch (orderDetailsBean.getOrderType()) {
                    case "3":
                        drawable = mContext.getResources().getDrawable(R.mipmap.collage);
                        break;
                    case "2":
                        drawable = mContext.getResources().getDrawable(R.mipmap.reserve);
                        break;
                    case "1":
                        drawable = mContext.getResources().getDrawable(R.mipmap.presale);
                        break;
                    default:

                        break;
                }
            }
            if (TextUtils.equals(orderDetailsBean.getGoodStatus(),"0")){
                ll_xiajia.setVisibility(View.VISIBLE);
            }else if (TextUtils.equals(orderDetailsBean.getGoodStatus(),"1")){
                ll_xiajia.setVisibility(View.GONE);
            }

            ImageSpan imageSpan = new ImageSpan(drawable);
            if (drawable == null) {
                tv_commodity_name.setText(orderDetailsBean.getGoodsName());
            } else {
                drawable.setBounds(0, 0, 100, 50);
                spannableString.setSpan(imageSpan, 0, 2, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
                tv_commodity_name.setText(spannableString);
            }

            Glide.with(mContext).load(Config.BASE_URL + orderDetailsBean.getGoodsUrl()).apply(Arad.opts).into(iv_commodity);
//            tv_commodity_name.setText(orderDetailsBean.getGoodsName());
            tv_commodity_info.setText(orderDetailsBean.getSkuContent());
            tv_commodity_num.setText("x" + orderDetailsBean.getQuantity());
            tv_commodity_price.setText("￥" + orderDetailsBean.getGoodsPrice());
        }
    }


}
